package com.example.springboot.modules.test.entity;

import com.example.springboot.modules.common.entity.AbstractEntity;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.persistence.*;
import java.util.List;

@Entity
@Table(name = "test_clazz")
public class Clazz extends AbstractEntity {
    private String clazzName;

    @ManyToMany(cascade = CascadeType.ALL)
    @JoinTable(name="test_clazz_student",
            joinColumns =@JoinColumn(name="clazz_id"),
            inverseJoinColumns = @JoinColumn(name = "student_id")
    )
    private List<Student> students;
    @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
    @JoinColumn(name="school_id",insertable = false,updatable = false)
    @JsonIgnore
    private School school;

    public String getClazzName() {
        return clazzName;
    }

    public void setClazzName(String clazzName) {
        this.clazzName = clazzName;
    }

    public List<Student> getStudents() {
        return students;
    }

    public void setStudents(List<Student> students) {
        this.students = students;
    }

    public School getSchool() {
        return school;
    }

    public void setSchool(School school) {
        this.school = school;
    }
}
